package com.falm.picturebackend.repository.impl;

import javax.annotation.Resource;

import com.falm.picturebackend.entity.BO.UserBO;
import com.falm.picturebackend.entity.DO.UserDO;
import org.springframework.stereotype.Repository;

import com.falm.picturebackend.dao.UserDODao;
import com.falm.picturebackend.entity.convert.UserConvert;
import com.falm.picturebackend.repository.UserRepository;

import java.util.List;

/**
 * @author Administrator
 */
@Repository
public class UserRepositoryImpl implements UserRepository {

    @Resource
    private UserDODao userDODao;

    @Override
    public UserBO getUserByUserAccount(String userAccount) {
        return UserConvert.do2BO(userDODao.getUserByUserAccount(userAccount));
    }

    @Override
    public void addUser(UserBO userBO) {
        userDODao.registerUser(UserConvert.bo2DO(userBO));
    }

    @Override
    public void deleteUser(String userAccount) {
        userDODao.deleteUser(userAccount);
    }

    @Override
    public void updateUser(UserBO userBO) {
        userDODao.updateUser(UserConvert.bo2DO(userBO));
    }

    @Override
    public List<UserBO> getUser(UserBO userBO, String sortField, String sortOrder) {
        List<UserDO> userDOList = userDODao.getUser(UserConvert.bo2DO(userBO), sortField, sortOrder);
        return UserConvert.do2BOList(userDOList);
    }
}
